# 合约表
import datetime

from exts import db


class AgreementType:
    SPORT = 1  # 体育
    POLITICS = 2  # 政治
    CURRENCY = 3  # 币圈
    ELECTRONIC = 4  # 电竞
    OTHER = 5  # 其他


class TYPE:
    PASS = 1 # 通过
    NOPASS = 2 # 未通过
    AUDIT = 3 # 审核中


class Agreement(db.Model):
    __tablename__ = 'agreement'  # 合约表名
    __searchable__ = ['title','content',]

    # 合约id
    id = db.Column(db.Integer, primary_key=True, unique=True, autoincrement=True)
    # 标题
    title = db.Column(db.String(30), nullable=False,unique=True)
    # 内容
    content = db.Column(db.Text, nullable=False,unique=True)
    # 类型，逻辑传参，看AgreementType类
    atype = db.Column(db.Integer, nullable=False, default=AgreementType.OTHER)
    # 结束时间
    end_time = db.Column(db.DateTime)
    # 创建合约的用户id
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'))
    # 审核状态
    status = db.Column(db.Integer, default=TYPE.AUDIT)
    # 创建的时间默认值
    add_time = db.Column(db.DateTime, default=datetime.datetime.now())

    def __str__(self):
        return self.title,self.content
